
/**
* 游戏初始化
* @param {null}
* @returns {null}
*/
function gameInit(enval) {
    if (playmusic == true) {
        musiclist2.push('./music/ready go.mp3');
        musicarr(musiclist2);
    }
    if (enval == '1' && playmusic == true) {
        document.getElementById('audio_music3').load();
    } else if (enval == '2' && playmusic == true) {
        document.getElementById('audio_music').load();
    }
    $("#main ").prepend(myblock.rawBlock());
    $("#again_game").css("display", "none");
    $("#move_game").css("display", "none");
    endcon = false;
    results = 0;
    tops = 2, speed = 15;
    dangwei = 1;
    blockofcolor = "black";
    $("#main").empty();
    movegame();
}


/**
 * 获取样式
 * @param {String | Object} obj 
 * @param {String | Object} css 
 * @returns {Number | String} 
 */
function getTocss(obj, css) {
    return $(obj).css(css);
}

/**
 * 把分数放进去，获得相对应得速度
 * @param {Number} n 
 * @returns {Number} 数字
 */
function upgRade(n) {
    if (n >= 5 && n < 20) {
        return 25;
    }
    if (n >= 20 && n < 35) {
        return 20;
    }
    if (n >= 35 && n < 50) {
        return 15;
    }
    if (n >= 50 && n < 65) {
        return 13;
    }
    if (n >= 65 && n < 80) {
        return 10;
    }
    if (n >= 80 && n < 95) {

        return 7;
    }
    if (n >= 100) {
        return 5;
    }
    if (n < 5) {
        return 30;
    }
}

//点击喇叭
$("#box #laba").click(function () {
    if ($(this).attr("data-laba") == 'yes') {
        $(this).attr("src", "./img/labaguan.png");
        $(this).attr("data-laba", 'no');
        $(this).css("opacity", 0.4);
        playmusic = false;
        document.getElementById('audio_music').pause();
        document.getElementById('audio_music2').pause();
        document.getElementById('audio_music3').pause();
        document.getElementById('audio_music4').pause();
        document.getElementById('audio_music5').pause();

    } else {
        $(this).attr("src", "./img/labakai.png");
        $(this).attr("data-laba", 'yes');
        playmusic = true;
        $(this).css("opacity", 0.7);
    }

})

/**
 * 把音乐的数组拿出来放歌
 * @param {Array} arr 
 */
function musicarr(arr) {
    let mp3 = arr[0];
    let mp = new Audio(mp3);
    mp.play();
    $(mp).bind("ended", function () {
        musiclist = [];
    });
}

$("#showpaimin").on("click",function(){
    $("#paiming").css("display", "block");
})
$("#paiming .exit span").on("click",function(){
    $("#paiming").css("display", "none");
})